Skip to content

Set sequences & handle spurious wakeups in RVC4 IMU#1727

Open
asahtik wants to merge 3 commits into
developfrom
bugfix/imu_sequence
Open

Set sequences & handle spurious wakeups in RVC4 IMU#1727
asahtik wants to merge 3 commits into
developfrom
bugfix/imu_sequence

Conversation

@asahtik
Copy link
Copy Markdown
Contributor

@asahtik asahtik commented Mar 19, 2026

Purpose

Specification

None / not applicable

Dependencies & Potential Impact

None / not applicable

Deployment Plan

None / not applicable

Testing & Validation

None / not applicable

Summary by CodeRabbit

  • Chores

    • Updated the device RVC4 component version to a new build identifier.
  • Tests

    • Added an IMU sensor test that runs the pipeline, polls accelerometer and gyroscope data for up to 10 seconds, and verifies at least one measurement is received and sensor packet sequences advance as expected.

Copilot AI review requested due to automatic review settings March 19, 2026 14:48
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 19, 2026

📝 Walkthrough

Walkthrough

This pull request updates a CMake configuration variable for RVC4 device versioning and adds a Catch2 test that validates IMU node sequence continuity by polling IMU packets from a running pipeline.

Changes

Cohort / File(s) Summary
CMake Configuration
cmake/Depthai/DepthaiDeviceRVC4Config.cmake
Updated DEPTHAI_DEVICE_RVC4_VERSION from 0.0.1+b96987e20d3e015dae8854b5fa8faa599c8d5ea8 to 0.0.1+40ac229a57372612e96393b2a6bf595a51b8ae88.
IMU Node Testing
tests/src/ondevice_tests/pipeline/node/imu_test.cpp
Added a new Catch2 test that builds and starts a dai::Pipeline with an IMU node (accelerometer + gyroscope @400Hz), configures batching, polls the IMU output queue for up to 10s, asserts sequence-increment per packet, and requires at least one message received.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through CMake with a careful cheer,
Tweaked a version string to bring it near,
Then watched IMU packets dance and play,
Sequences climbing as they sway,
A tiny rabbit celebrates the test today!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references setting sequences and handling spurious wakeups in RVC4 IMU, which directly matches the changes: updating a version variable and adding an IMU test that validates sequence updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/imu_sequence
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch bugfix/imu_sequence

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the on-device IMU test suite to better detect cases where IMU packets are emitted without any sensor report actually advancing (e.g., due to spurious wakeups), and bumps the tracked RVC4 device snapshot version.

Changes:

  • Add a new IMU test that asserts at least one of the accelerometer/gyroscope sequence numbers advances across received packets.
  • Configure IMU batching parameters for the new test case.
  • Update the RVC4 device snapshot version string in CMake config.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tests/src/ondevice_tests/pipeline/node/imu_test.cpp Adds a new Catch2 test that validates IMU packet sequence advancement over time.
cmake/Depthai/DepthaiDeviceRVC4Config.cmake Updates the pinned RVC4 snapshot version identifier.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

dai::IMUPacket previousPacket;

while(pipeline.isRunning() && std::chrono::steady_clock::now() - start <= std::chrono::seconds(10)) {
auto imuData = imuQueue->get<dai::IMUData>();
Comment on lines +60 to +66
dai::IMUPacket previousPacket;

while(pipeline.isRunning() && std::chrono::steady_clock::now() - start <= std::chrono::seconds(10)) {
auto imuData = imuQueue->get<dai::IMUData>();
if(imuData == nullptr) continue;

for(const auto& imuPacket : imuData->packets) {
Comment on lines +66 to +69
for(const auto& imuPacket : imuData->packets) {
REQUIRE((imuPacket.acceleroMeter.sequence > previousPacket.acceleroMeter.sequence || imuPacket.gyroscope.sequence > previousPacket.gyroscope.sequence));
previousPacket = imuPacket;
}
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/src/ondevice_tests/pipeline/node/imu_test.cpp`:
- Line 45: Rename the test case string in the TEST_CASE invocation to a more
descriptive name that reflects its intent (e.g., "Test IMU sequence numbers
strictly increase" or "Test IMU packets contain new data (no spurious
wakeups)"); locate the TEST_CASE(...) macro in imu_test.cpp (the TEST_CASE
symbol) and replace the current literal "At least one measurement should be
updated" with the chosen clearer description, and update any test
documentation/comments or related assertions if they reference the old name.
- Around line 45-73: The test currently can pass without receiving IMU data;
modify the test that uses imu, imuQueue, previousPacket and the while loop to
track whether any imu packets were observed (e.g., increment a counter or set a
boolean inside the for(const auto& imuPacket : imuData->packets) loop) and after
pipeline.stop() add a REQUIRE that asserts at least one packet was received
(e.g., REQUIRE(receivedCount > 0) or REQUIRE(receivedAny == true)) so the test
fails if no IMU data arrived.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4abe5c65-c2d2-4ba8-aa18-899c3571cfd7

📥 Commits

Reviewing files that changed from the base of the PR and between 8b49e0d and fca5575.

📒 Files selected for processing (2)
  • cmake/Depthai/DepthaiDeviceRVC4Config.cmake
  • tests/src/ondevice_tests/pipeline/node/imu_test.cpp
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Upload results
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-03-16T11:17:12.819Z
Learnt from: pheec
Repo: luxonis/depthai-core PR: 1715
File: include/depthai/pipeline/node/PointCloud.hpp:34-98
Timestamp: 2026-03-16T11:17:12.819Z
Learning: In `include/depthai/pipeline/node/PointCloud.hpp`, the nested `Impl` class inside `PointCloud` is intentionally public (not private/forward-declared) because the on-host unit tests in `tests/src/onhost_tests/point_cloud_test.cpp` directly access `Impl` methods such as `setIntrinsics`, `setExtrinsics`, `useCPU`, `useCPUMT`, `computePointCloudDense`, `applyTransformation`, and `filterValidPoints`. Do not suggest making `Impl` private or forward-declaring it.

Applied to files:

  • tests/src/ondevice_tests/pipeline/node/imu_test.cpp
🪛 Cppcheck (2.20.0)
tests/src/ondevice_tests/pipeline/node/imu_test.cpp

[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)

🔇 Additional comments (2)
cmake/Depthai/DepthaiDeviceRVC4Config.cmake (1)

6-6: LGTM! Firmware version updated for RVC4 device.

The version update from b96987e2... to 40ac229a... aligns with the firmware changes mentioned in the PR title for handling IMU sequences and spurious wakeups.

tests/src/ondevice_tests/pipeline/node/imu_test.cpp (1)

3-3: LGTM! Necessary include for time-bounded test loop.

The <chrono> header is correctly added to support the time-bounded polling logic in the new test case.

basicIMUTest(480.0f, {dai::IMUSensor::GYROSCOPE_RAW}, 0.8f); // TODO(Morato) - debug why some devices need so much tolerance
}

TEST_CASE("At least one measurement should be updated") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider a more descriptive test name.

The current name "At least one measurement should be updated" could be clearer. Consider renaming to something like "Test IMU sequence numbers strictly increase" or "Test IMU packets contain new data (no spurious wakeups)" to better reflect the test's purpose.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/src/ondevice_tests/pipeline/node/imu_test.cpp` at line 45, Rename the
test case string in the TEST_CASE invocation to a more descriptive name that
reflects its intent (e.g., "Test IMU sequence numbers strictly increase" or
"Test IMU packets contain new data (no spurious wakeups)"); locate the
TEST_CASE(...) macro in imu_test.cpp (the TEST_CASE symbol) and replace the
current literal "At least one measurement should be updated" with the chosen
clearer description, and update any test documentation/comments or related
assertions if they reference the old name.

Comment thread tests/src/ondevice_tests/pipeline/node/imu_test.cpp
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/src/ondevice_tests/pipeline/node/imu_test.cpp`:
- Around line 51-52: The test sets imu->setMaxBatchReports(20) which exceeds the
documented maximum of 5; update the IMU setter and/or the test: in the IMU class
(function IMU::setMaxBatchReports in src/pipeline/node/IMU.cpp) add
validation/clamping to enforce the documented limit (e.g., clamp value to 5 or
return/error when >5) and update the unit test in imu_test.cpp to use an allowed
value (<=5) such as 5 so it matches include/depthai/properties/IMUProperties.hpp
documentation and avoids firmware violations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 351f4410-61e2-43c5-afb8-f30497693082

📥 Commits

Reviewing files that changed from the base of the PR and between fca5575 and e755f01.

📒 Files selected for processing (1)
  • tests/src/ondevice_tests/pipeline/node/imu_test.cpp
📜 Review details
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-03-16T11:17:12.819Z
Learnt from: pheec
Repo: luxonis/depthai-core PR: 1715
File: include/depthai/pipeline/node/PointCloud.hpp:34-98
Timestamp: 2026-03-16T11:17:12.819Z
Learning: In `include/depthai/pipeline/node/PointCloud.hpp`, the nested `Impl` class inside `PointCloud` is intentionally public (not private/forward-declared) because the on-host unit tests in `tests/src/onhost_tests/point_cloud_test.cpp` directly access `Impl` methods such as `setIntrinsics`, `setExtrinsics`, `useCPU`, `useCPUMT`, `computePointCloudDense`, `applyTransformation`, and `filterValidPoints`. Do not suggest making `Impl` private or forward-declaring it.

Applied to files:

  • tests/src/ondevice_tests/pipeline/node/imu_test.cpp
📚 Learning: 2026-03-24T22:39:05.647Z
Learnt from: MaticTonin
Repo: luxonis/depthai-core PR: 1732
File: src/pipeline/Pipeline.cpp:705-705
Timestamp: 2026-03-24T22:39:05.647Z
Learning: In `src/pipeline/Pipeline.cpp`, within `PipelineImpl::build()`, the condition `autoCalibrationString != "OFF" && autoCalibrationString != ""` intentionally retains the empty-string check. Even though `utility::getEnvAs<std::string>("DEPTHAI_AUTOCALIBRATION", "ON_START")` provides a default of `"ON_START"`, the explicit `!= ""` guard is kept on purpose and should not be flagged as redundant in future reviews.

Applied to files:

  • tests/src/ondevice_tests/pipeline/node/imu_test.cpp
🪛 Cppcheck (2.20.0)
tests/src/ondevice_tests/pipeline/node/imu_test.cpp

[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)


[information] 3-3: Include file

(missingIncludeSystem)

🔇 Additional comments (2)
tests/src/ondevice_tests/pipeline/node/imu_test.cpp (2)

3-3: LGTM!

The <chrono> include is correctly added to support std::chrono::steady_clock::now() and std::chrono::seconds() used in the new test.


60-73: Test logic for sequence validation is sound.

The use of an OR condition (||) in the sequence check at line 71 is appropriate. Per the IMUPacket documentation: "Only the enabled outputs are populated," so each sensor may advance independently. The assertion correctly verifies that at least one sensor's sequence has increased, which detects spurious wakeups (where a wakeup occurs but no new data is available).

The numMessages > 0 assertion at line 76 properly addresses the concern about the test passing trivially if no data is received.

Comment on lines +51 to +52
imu->setBatchReportThreshold(10);
imu->setMaxBatchReports(20);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify maxBatchReports constraint documentation and runtime handling

# Check the IMUProperties documentation
echo "=== IMUProperties maxBatchReports documentation ==="
rg -n -A2 -B2 'maxBatchReports' --type=cpp

# Check if there's any validation/clamping logic for maxBatchReports
echo ""
echo "=== Searching for validation of maxBatchReports ==="
rg -n -C5 'setMaxBatchReports' --type=cpp

Repository: luxonis/depthai-core

Length of output: 12251


setMaxBatchReports(20) exceeds the documented maximum of 5.

According to include/depthai/properties/IMUProperties.hpp:172-173, maxBatchReports is documented as "Maximum 5," yet the test sets this to 20. The setter in src/pipeline/node/IMU.cpp:42-43 does not validate or clamp this value, so undefined behavior or firmware-level constraint violations are possible.

🔧 Proposed fix
     imu->setBatchReportThreshold(10);
-    imu->setMaxBatchReports(20);
+    imu->setMaxBatchReports(5);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
imu->setBatchReportThreshold(10);
imu->setMaxBatchReports(20);
imu->setBatchReportThreshold(10);
imu->setMaxBatchReports(5);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/src/ondevice_tests/pipeline/node/imu_test.cpp` around lines 51 - 52,
The test sets imu->setMaxBatchReports(20) which exceeds the documented maximum
of 5; update the IMU setter and/or the test: in the IMU class (function
IMU::setMaxBatchReports in src/pipeline/node/IMU.cpp) add validation/clamping to
enforce the documented limit (e.g., clamp value to 5 or return/error when >5)
and update the unit test in imu_test.cpp to use an allowed value (<=5) such as 5
so it matches include/depthai/properties/IMUProperties.hpp documentation and
avoids firmware violations.

@asahtik asahtik added testable PR is ready to be tested - run vanilla tests and removed testable PR is ready to be tested - run vanilla tests labels Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants